﻿using System;
using System.Collections.Generic;


public class GameCfgData : ImplData
{

	public class GameCfg
	{
		public string gameType = "";
		public float speed = 4f;
		public List<float> gudian = new List<float>();
		public List<float> gudian2 = new List<float> ();
		public string urlMusic = "";

	}

	private Dictionary<string, GameCfg> d = new Dictionary<string, GameCfg> ();

	protected override int Deserialize()
	{

		if (string.IsNullOrEmpty(jsonText))
			return -1;

		data = MiniJSON.Json.Deserialize(jsonText) as Dictionary<string, object>;

		foreach (var item in data) {
		
			GameCfg gamecfg = new GameCfg ();
			Dictionary<string, object> dict = item.Value as Dictionary<string, object>;
			gamecfg.gameType = dict ["type"] as string;
			gamecfg.speed = Convert.ToSingle (dict ["speed"]);
			gamecfg.urlMusic = dict ["urlMusic"] as string;
			List<object> l  = dict ["gudian"] as List<object>;

			foreach (var f in l) {
			
				gamecfg.gudian.Add (Convert.ToSingle(f));
			}

			List<object> ll  = dict ["gudian2"] as List<object>;

			foreach (var f in ll) {

				gamecfg.gudian2.Add (Convert.ToSingle(f));
			}

			d.Add (item.Key, gamecfg);

		}
			
		return 0;
	}
		
	public GameCfg GetCfg( string id )
	{
		if (d.ContainsKey (id))
			return d [id];
		else
			return null;
	}
		

}


